<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Dbview_model extends Model 
{
	function __construct()
	{     
		parent::Model();
	}

    function getdb()
    {
        if($this->slug != FALSE){
            $query = $this->db->getwhere('view', array('slug' => $this->slug), 1);
            if($query->num_rows() == 0) {
                redirect('admin/add_edit_page', 'location');
            }else{

                $dbdata = $query->row_array();
                $this->vid = $dbdata['id'];
                $this->dbdata = delids($dbdata);
                //$this->tpl = array_merge($this->tpl, $this->dbdata);
            }
        }else{
            $fields = $this->db->list_fields('view');
            foreach ($fields as $field) $this->dbdata[$field] = '';
            $this->dbdata = delids($this->dbdata);
            //$this->tpl = array_merge($this->tpl, $this->dbdata);
        }
    }
}
?>
